<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p>整数1：<input type="text" id="yi"/></p>
		<p>整数2：<input type="text" id="er"/></p>
		<p>
			<button onclick="up(1)">加</button>
			<button onclick="up(2)">减</button>
			<button onclick="up(3)">乘</button>
			<button onclick="up(4)">除</button>
		</p>
		<p>结果：<input type="text" id="jieguo"/></p>
		
		<script type="text/javascript">
			function up(n){
				var a = Number(document.getElementById("yi").value);
				var b = Number(document.getElementById("er").value);
				var c = 0;
				if(n == 1){
					c = a + b;
				}else if(n== 2){
					c = a - b;
				}else if (n== 3){
					c = a * b;
				}else if (n == 4){
					if(b ==0){
						alert('被除数不可以是0！')
					}else{
						c = a / b;
					}
				}
				document.getElementById('jieguo').value = c;
			}
		</script>
	</body>
</html>
